package org.firebug.spring.boot.swagger.api.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.firebug.common.core.dict.Gender;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;

@Data
@ApiModel("用户DTO")
public class UserDTO {
    @NotNull(message = "salary required", groups = {Modify.class})
    @ApiModelProperty(value = "id", required = false, example = "1")
    private Long id;

    @NotBlank(message = "name not blank")
    @Pattern(regexp = "^[A-Za-z0-9]{6,8}$")
    @ApiModelProperty(value = "姓名", required = true, example = "felix")
    private String name;

    @NotNull(message = "salary not null")
    @DecimalMin(value = "3000", message = "salary in [3000,8000]")
    @DecimalMax(value = "8000", message = "salary in [3000,8000]")
    @ApiModelProperty(value = "薪资", required = true, example = "3000.99")
    private BigDecimal salary;

    @NotNull(message = "gender not null")
    @ApiModelProperty(value = "性别", required = true, example = "M")
    private Gender gender;

    @NotNull(message = "birthDate not null", groups = {Save.class})
    @Past(message = "past date", groups = {Save.class})
    @ApiModelProperty(value = "生日", required = true, example = "2008-11-04")
    @JsonFormat(pattern="yyyy-MM-dd", timezone="GMT+8")
    private Date birthDate;

    public interface Save {}
    public interface Modify {}
}
